package com.xbongbong.pro.sharepermission.pojo;

import com.xbongbong.pro.enums.ConditionOperatorEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 李翔
 * @date 2023/3/9
 * @description
 */
@Getter
@Setter
@ToString
public class SharePermissionJointConditionPojo {
    /**
     * 条件组
     */
    @Valid
    @Size(max = 5, message = "{dto.msg.conditionNode.conditions.Size.max}")
    @NotNull(message = "{dto.msg.SharePermissionSaveDTO.SharePermissionJointConditionPojo.filters.NotNull}")
    @NotEmpty(message = "{dto.msg.SharePermissionSaveDTO.SharePermissionJointConditionPojo.filters.NotNull}")
    private List<SharePermissionConditionFilters> filters;

    /**
     * 且或 标记
     * @see com.xbongbong.pro.enums.ConditionOperatorEnum
     */
    @NotBlank(message = "{dto.msg.SharePermissionSaveDTO.SharePermissionJointConditionPojo.operator.NotNull}")
    private String operator;

    public SharePermissionJointConditionPojo() {
        filters = new ArrayList<>();
        operator = ConditionOperatorEnum.OR.getAlias();
    }
}
